<template>
	<view>
		<view class="bg-white radius10 padding-sm margin-sm" v-for='(item,index) in list' :key='index'>
			<view class="flex justify-between align-center text-bold">
				<view class="text-15 text-333">
					订单编号{{item.orderNo}}
				</view>
				<view class="text-sm color">
					<block v-if='item.status==0'>待发货</block>
					<block v-if='item.status==1'>配送中</block>
					<block v-if='item.status==2'>已收货</block>
					<block v-if='item.status==3'>已评价</block>
					<block v-if='item.status==4'>已取消</block>
					
				</view>
			</view>
			<view @click="toPage('/filePage/pages/goods-detail/goods-detail?id=' + val.productId)"
				class="flex  justify-start margin-top" >
				<image :src="item.productPic" mode="" style="width: 166rpx;height: 166rpx;min-width: 166rpx;">
				</image>
				<view class="margin-left-sm flex-treble">
					<view class="text-13 text-333 flex justify-between">
		
						<view class="text-cut-2" style="width: 300rpx;max-width: 300rpx;">
							{{item.productName}}
						</view>
						</view>
					
				</view>
			</view>
			<view class="flex justify-end align-center text-df margin-top">
				<view class="text-999">
					使用积分:{{item.usePoints}}
				</view>
				
			
			</view>
			<view class="flex justify-end align-center margin-top">
				<button v-if="item.status==1" @click="updateStatus(item.id)"  
				class="btn2 btn round text-13 margin-left text-white text-999" >收货</button>
			
				
			</view>
		</view>
		<uni-load-more :status="loading" />
	</view>
</template>

<script>
	import BetterPull from '@/common/util/BetterPull'
	export default {
		mixins: [
			BetterPull({
				async getPage(page, done) {
					this.loading = 'loading';
					const obj = {
						pageNum: page,
						pageSize: 10,
					
					}
				
		
					const [err, res] = await this.$get(this.$api.pointList, obj)
					if (res) {
						var data = res.data.list
						done(data);
						if (data.length < 10) {
							this.loading = 'noMore';
						} else {
							this.loading = 'more';
						}
		
					}
					if (err) {
						done([]);
						this.loading = 'noMore';
					}
				}
			})
		],
		data() {
			return {
				loading: "more",
			}
		},
		onLoad() {
			
		},
		methods: {
			
			 updateStatus(id){
				 const that = this
				uni.showModal({
				  content: '你确定收货吗',
				    success: function (res) {
				        if (res.confirm) {
							const data ={orderPointId:id}
							that.$get(that.$api.pointPayConfirm,data).then(res=>{
								const [err,rs] = res
								if(rs){
									that.$util.msg(rs.message)
									that.Refresh()
									
								}
							})
							
				            console.log('用户点击确定');
				        } else if (res.cancel) {
				            console.log('用户点击取消');
				        }
				    }
				});
			}
		}
	}
</script>

<style scoped>
    .btn{
		background: linear-gradient(90deg, #F16347, #EE0979);
		padding:  20rpx 40rpx;
		color:#fff;
	}
</style>
